package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BuzTaskAwards;
import com.ruoyi.system.service.IBuzTaskAwardsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动奖项Controller
 * 
 * @author ruoyi
 * @date 2023-08-27
 */
@RestController
@RequestMapping("/system/buzTaskAwards")
public class BuzTaskAwardsController extends BaseController
{
    @Autowired
    private IBuzTaskAwardsService buzTaskAwardsService;

    /**
     * 查询活动奖项列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskAwards:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzTaskAwards buzTaskAwards)
    {
        startPage();
        List<BuzTaskAwards> list = buzTaskAwardsService.selectBuzTaskAwardsList(buzTaskAwards);
        return getDataTable(list);
    }

    /**
     * 导出活动奖项列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskAwards:export')")
    @Log(title = "活动奖项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzTaskAwards buzTaskAwards)
    {
        List<BuzTaskAwards> list = buzTaskAwardsService.selectBuzTaskAwardsList(buzTaskAwards);
        ExcelUtil<BuzTaskAwards> util = new ExcelUtil<BuzTaskAwards>(BuzTaskAwards.class);
        util.exportExcel(response, list, "活动奖项数据");
    }

    /**
     * 获取活动奖项详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskAwards:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(buzTaskAwardsService.selectBuzTaskAwardsById(id));
    }

    /**
     * 新增活动奖项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskAwards:add')")
    @Log(title = "活动奖项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzTaskAwards buzTaskAwards)
    {
        return success(buzTaskAwardsService.insertBuzTaskAwards(buzTaskAwards));
    }

    /**
     * 修改活动奖项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskAwards:edit')")
    @Log(title = "活动奖项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzTaskAwards buzTaskAwards)
    {
        return toAjax(buzTaskAwardsService.updateBuzTaskAwards(buzTaskAwards));
    }

    /**
     * 删除活动奖项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskAwards:remove')")
    @Log(title = "活动奖项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buzTaskAwardsService.deleteBuzTaskAwardsByIds(ids));
    }
}
